package utils

type ordinal interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64
}

func Min[T ordinal](a, b T) T {
	if a > b {
		return b
	}
	return a
}

func Max[T ordinal](a, b T) T {
	if a < b {
		return b
	}
	return a
}

func FileOrDirExists(filename string) bool {
	_, err := os.Stat(filename)
	return !os.IsNotExist(err)
}

func AddResizeParamForPicUrl(picurl string, size int64) string {
	if picurl == "" {
		return ""
	}

	return fmt.Sprintf("%s?param=%dy%d", picurl, size, size)
}

func IsSameDate(t1, t2 time.Time) bool {
	y1, m1, d1 := t1.Date()
	y2, m2, d2 := t2.Date()

	return y1==y2 && m1==m2 && d1==d2
}

func FileUrl(filePath string) string {
	return "file://" + filePath
}

func WebUrlOfAlbum(artistId int64) string {
	// IMPROVE: Hard Code, maybe define as external .env file or config file
	return "https://music.163.com/#album?id=" + strconv.FormatInt(artistId, 10)
}



